package cn.blogsx.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDemo01 {
    public static void main(String[] args) throws Exception {
        //1.导入驱动jar包
        //1.1 新建libs文件夹,右键添加为Library
        //2.注册驱动
        Class.forName("com.mysql.jdbc.Driver");

        //3.获取数据库连接对象
        Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctest", "root", "root");
        
        //4.定义sql语句
        String sql = "update user set sex = '女'  where id = 1 ";

        //5.获取执行sql的对象
        Statement stmt = connection.createStatement();

        //6.执行sql
        int i = stmt.executeUpdate(sql);

        //7.处理结果
        System.out.println(i);

        //8.释放资源
        stmt.close();
        connection.close();

    }
}
